﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using Portal.Web.Model;
using Portal.Web.Utility;
using Portal.Exam.Bussiness;
using Portal.Exam.Model;
using Portal.Core;

namespace Portal.Exam.Render
{
    public class Question
    {
        [AjaxPro.AjaxMethod]
        public static string GetHtml(string SiteId, string FirstGroupQuestionId,string FirstMonthiId,string Type, string Keyword, string SelectLevel, int CurrentPageIndex)
        {
            try
            {
                WebSessionUtility.CheckSessionTimeOut();

                GroupQuestionCls[] GroupQuestions = GroupQuestionBll.ReadingGroupQuestion(SiteId, "");
                string SelectGroupQuestionText = "<select class=drplist id=drpSelectGroupQuestion onchange=javascript:DetectMonthi();>";
                for (int iIndex = 0; iIndex < GroupQuestions.Length; iIndex++)
                {
                    string GroupQuestionId = (string)GroupQuestions[iIndex].GroupQuestionId;
                    string Name = (string)GroupQuestions[iIndex].GroupQuestionName;
                    if (FirstGroupQuestionId.Trim().Length == 0 && iIndex == 0)
                    {
                        FirstGroupQuestionId = GroupQuestionId;
                    }
                    if (FirstGroupQuestionId.Equals(GroupQuestionId))
                    {
                        SelectGroupQuestionText += "<option selected value=\"" + GroupQuestionId + "\">" + Name + "</option>";
                    }
                    else
                    {
                        SelectGroupQuestionText += "<option value=\"" + GroupQuestionId + "\">" + Name + "</option>";
                    }
                }
                SelectGroupQuestionText += "</select>";

                DataTable dtMonthi = new MonthiBll().ReadingMonthi(SiteId, FirstGroupQuestionId, "");
                string SelectMonthiText = "<select class=drplist id=drpSelectMonthi onchange=javascript:ResetSearch();>";
                for (int iIndex = 0; iIndex < dtMonthi.Rows.Count; iIndex++)
                {
                    string MonthiId = (string)dtMonthi.Rows[iIndex]["MonthiId"];
                    string Name = (string)dtMonthi.Rows[iIndex]["Name"];
                    if (FirstMonthiId.Trim().Length == 0 && iIndex == 0)
                    {
                        FirstMonthiId = MonthiId;
                    }
                    if (FirstMonthiId.Equals(MonthiId))
                    {
                        SelectMonthiText += "<option selected value=\"" + MonthiId + "\">" + Name + "</option>";
                    }
                    else
                    {
                        SelectMonthiText += "<option value=\"" + MonthiId + "\">" + Name + "</option>";
                    }
                }
                SelectMonthiText += "</select>";

              

                string[] Types = new string[]{
                    "BestAnswer","YesNo"//,"MultiChoice"
                };
                string[] SubjectTypes = new string[]{
                    "Câu hỏi 1 phương án đúng nhất","Câu hỏi dạng đúng hoặc sai"//,"Các đáp án đúng"
                };

                string SelectTypeText = "<select class=drplist id=drpSelectType onchange=javascript:JumPageQuestion(0);>";
                for (int iIndex = 0; iIndex < Types.Length; iIndex++)
                {
                    if (Types.Length == 0 && iIndex == 0)
                    {
                        Type = Types[iIndex];
                    }
                    if (Type.ToLower().Equals(Types[iIndex].ToLower()))
                    {
                        SelectTypeText += "<option selected value=\"" + Types[iIndex] + "\">" + SubjectTypes[iIndex] +" ("+Types[iIndex]+") </option>";
                    }
                    else
                    {
                        SelectTypeText += "<option value=\"" + Types[iIndex] + "\">" + SubjectTypes[iIndex] +" ("+Types[iIndex]+")</option>";
                    }
                }
                SelectTypeText += "</select>";

                DataTable dtQuestion = new QuestionBll().ReadingQuestion(SiteId, FirstMonthiId, Type, SelectLevel, null, Keyword);
            
                string SelectLevelText =
                    "<select id=drpSelectLevelQuestion class=drplist>\r\n" +
                    "   <option value=\"0\">Mức độ dễ</option>\r\n" +
                    "   <option value=\"1\">Mức độ trung bình</option>\r\n" +
                    "   <option value=\"2\">Mức độ khó</option>\r\n" +
                    "</select>\r\n";

                if (SelectLevel.Equals("1"))
                {
                    SelectLevelText =
                      "<select id=drpSelectLevelQuestion class=drplist>\r\n" +
                      "   <option value=\"0\">Mức độ dễ</option>\r\n" +
                      "   <option value=\"1\" selected>Mức độ trung bình</option>\r\n" +
                      "   <option value=\"2\">Mức độ khó</option>\r\n" +
                      "</select>\r\n";
                }
                if (SelectLevel.Equals("2"))
                {
                    SelectLevelText =
                      "<select id=drpSelectLevelQuestion class=drplist>\r\n" +
                      "   <option value=\"0\">Mức độ dễ</option>\r\n" +
                      "   <option value=\"1\">Mức độ trung bình</option>\r\n" +
                      "   <option value=\"2\" selected>Mức độ khó</option>\r\n" +
                      "</select>\r\n";
                }
                
                
                ReturnPaging OReturnPaging = WebPaging.GetPaging(dtQuestion.Rows.Count, CurrentPageIndex, 30, 10, "JumPageQuestion");
                string RetHtml =
                    " <div class=CssFormSaveUpdate>\r\n"+
                    "   <table>"+
                    "       <tr>" +
                    "           <td class=Col1>Nhóm câu hỏi:</td>" +
                    "           <td class=Col2>" + SelectGroupQuestionText + "</td>" +
                    "       </tr>" +
                    "       <tr>" +
                    "           <td class=Col1>Loại câu hỏi:</td>" +
                    "           <td class=Col2><div id=divMonthiContent>" + SelectMonthiText + "</div></td>" +
                    "       </tr>" +
                    "       <tr>"+
                    "           <td class=Col1>Kiểu câu hỏi:</td>" +
                    "           <td class=Col2>" + SelectTypeText + "</td>" +
                    "       </tr>"+
                    "       <tr>" +
                    "           <td class=Col1>Mức độ:</td>" +
                    "           <td class=Col2>" + SelectLevelText + "</td>" +
                    "       </tr>" +
                    "       <tr>" +
                    "           <td class=Col1>Từ khóa: </td>" +
                    "           <td class=Col2><input class=textbox type=textbox id=txtKeyword value=\"" + Keyword + "\"></td>" +
                    "       </tr>" +
                    "       <tr>" +
                    "           <td class=Col1></td>" +
                    "           <td class=Col2><input type=button class=button value=\"Tìm câu hỏi theo điều kiện\" onclick=JumPageQuestion(0);></td>" +
                    "       </tr>" +
                    "   </table>"+
                    " </div>\r\n"+
                    "   <div id=divProcessing></div>"+
                    //"   <div id=divResultInfo class=cssTotalResultInfo>Số bản ghi thỏa mãn điều kiện tìm: "+dtQuestion.Rows.Count.ToString("#,##0")+"</div>" +
                    OReturnPaging.PagingText+
                    "   <div id=divResultContent class=\"tabcontent\">"+
                    "   <table style=\"width:100%\">" +
                    "       <tr>" +
                    "           <th>#</th>" +
                    "           <th>Câu hỏi</th>" +
                    "           <th style=\"text-align:right\">Điểm</th>" +
                    "           <th></th>" +
                    "           <th></th>" +
                    "           <th></th>" +
                    "           <th></th>" +
                    "       </tr>";

                for (int iIndex = OReturnPaging.StartIndex; iIndex < OReturnPaging.EndIndex; iIndex++)
                {
                    string QuestionId = (string)dtQuestion.Rows[iIndex]["QuestionId"];
                    string QuestionName = (string)dtQuestion.Rows[iIndex]["Title"];
                    int MaxPoint = (int)dtQuestion.Rows[iIndex]["MaxPoint"];
                    string DeleteUrl = "javascript:ClientDeleteQuestion('" + QuestionId + "')";
                    string MoveUrl = "javascript:ClientMoveQuestion('" + QuestionId + "')";
                    string HtmlEditorUrl = "javascript:ShowClientHtmlEditorForm('" + QuestionId + "')";
                    RetHtml +=
                    "       <tr onMouseOver=\"this.className='highlight'\" onMouseOut=\"this.className='normal'\">" +
                    "           <td class=tdIndex>" + (iIndex+1) + "</td>" +
                    "           <td>" + QuestionName + "</td>" +
                    "           <td class=tdIndex>" + MaxPoint.ToString("#,##0") + "</td>" +
                    "           <td class=tdButton><a href=\"javascript:ShowClientUpdateUrlForm('" + QuestionId + "');\">Sửa</a></td>" +
                    "           <td class=tdButton><a href=\"" + DeleteUrl + "\">Xóa</a></td>" +
                    "           <td class=tdButton><a href=\"" + MoveUrl + "\">Chuyển</a></td>" +
                    "           <td class=tdButton><a href=\"" + HtmlEditorUrl + "\">HtmlEditor</a></td>" +
                    "       </tr>";
                }
                RetHtml +=
                    "   </table>\r\n"+
                    "</div>";
                return RetHtml;
            }
            catch (Exception ex)
            {
                return ex.Message.ToString();
            }
        }

        [AjaxPro.AjaxMethod]
        public string GetMonthi(string SiteId,string FirstGroupQuestionId)
        {
            try
            {
                WebSessionUtility.CheckSessionTimeOut(); 
                DataTable dtMonthi = new MonthiBll().ReadingMonthi(SiteId, FirstGroupQuestionId, "");
                string SelectMonthiText = "<select class=drplist id=drpSelectMonthi onchange=javascript:ResetSearch();>";
                for (int iIndex = 0; iIndex < dtMonthi.Rows.Count; iIndex++)
                {
                    string MonthiId = (string)dtMonthi.Rows[iIndex]["MonthiId"];
                    string Name = (string)dtMonthi.Rows[iIndex]["Name"];
                    SelectMonthiText += "<option value=\"" + MonthiId + "\">" + Name + "</option>";
                }
                SelectMonthiText += "</select>";
                return SelectMonthiText;
            }
            catch (Exception ex)
            {
                return ex.Message.ToString();
            }
        }

        public static AjaxOut Draw(string SiteId)
        {
            AjaxOut OAjaxOut = new AjaxOut();
            try
            {
                string GroupQuestionId = (string)WebEnvironments.Request(SiteId, "GroupQuestionId");
                if (string.IsNullOrEmpty(GroupQuestionId)) GroupQuestionId = "";
                string MonThiId = (string)WebEnvironments.Request(SiteId, "MonThiId");
                if (string.IsNullOrEmpty(MonThiId)) MonThiId = "";
                string Type = (string)WebEnvironments.Request(SiteId, "Type");
                if (string.IsNullOrEmpty(Type)) Type = "";
                SiteParam OSiteParam = WebEnvironments.CreateSiteParam(SiteId);
                string IconRoot = WebConfig.GetButtonIconRoot(OSiteParam);
      

                string RetHtml =
                        "<script language=javascript>\r\n" +
                        " function ClientAddQuestion()\r\n" +
                        " {\r\n" +
                        "     SiteId='"+SiteId+"';\r\n"+
                        "     MonthiId=document.getElementById(\"drpSelectMonthi\").options[document.getElementById(\"drpSelectMonthi\").selectedIndex].value;\r\n" +
                        "     Type=document.getElementById(\"drpSelectType\").options[document.getElementById(\"drpSelectType\").selectedIndex].value;\r\n" +
                        "     Url=Portal.Exam.Render.Question.GetAddQuestionUrl(SiteId, MonthiId, Type).value;\r\n" +
                        "     if(Url.indexOf(\"ERROR\")!=-1)\r\n" +
                        "     {\r\n" +
                        "         alert(Url);\r\n" +
                        "         return;\r\n" +
                        "     }\r\n" +
                        "     window.open(Url, '_self'); \r\n" +
                        " } \r\n" +
                        " function ClientDeleteQuestion(QuestionId) \r\n" +
                        " { \r\n" +
                        "     SiteId='" + SiteId + "';\r\n" +
                        "     Msg=Portal.Exam.Render.Question.ServerSideCheckDeleteQuestion(SiteId).value; \r\n" +
                        "     if(Msg.indexOf(\"ERROR\")!=-1) \r\n" +
                        "     { \r\n" +
                        "         alert(Msg); \r\n" +
                        "         return; \r\n" +
                        "     } \r\n" +
                        "     Msg=Portal.Exam.Render.Question.GetConfirmDeleteMsg(SiteId).value; \r\n" +
                        "     if(confirm(Msg)==false)return; \r\n" +
                        "     RetValue = Portal.Exam.Render.Question.ServerSideDeleteQuestion(SiteId, QuestionId).value; \r\n" +
                        "     if(RetValue.indexOf(\"ERROR\")!=-1) \r\n" +
                        "     { \r\n" +
                        "         alert(RetValue); \r\n" +
                        "         return; \r\n" +
                        "     } \r\n" +
                        "     alert(RetValue); \r\n" +
                        "     RealJumpPageQuestion(); \r\n" +
                        " } \r\n" +

                        " function ShowClientUpdateUrlForm(QuestionId) \r\n" +
                        " { \r\n" +
                        "     SiteId='" + SiteId + "';\r\n" +
                        "     Url=Portal.Exam.Render.Question.GetShowUpdateForm(SiteId, QuestionId).value; \r\n" +
                        "     if(Url.indexOf(\"ERROR\")!=-1) \r\n" +
                        "     { \r\n" +
                        "         alert(Url); \r\n" +
                        "         return; \r\n" +
                        "     } \r\n" +
                        "     window.open(Url, '_self');  \r\n" +
                        " } \r\n" +

                        " function DetectMonthi() \r\n" +
                        " { \r\n" +
                        "     SiteId='"+SiteId+"';\r\n"+
                        "     GroupQuestionId=document.getElementById(\"drpSelectGroupQuestion\").options[document.getElementById(\"drpSelectGroupQuestion\").selectedIndex].value; \r\n" +
                        "     retValue=Portal.Exam.Render.Question.GetMonthi(SiteId, GroupQuestionId).value; \r\n" +
                        "     document.getElementById(\"divMonthiContent\").innerHTML=retValue; \r\n" +
                        "     document.getElementById(\"divProcessing\").innerHTML=\"\"; \r\n" +
                        "     document.getElementById(\"divResultContent\").innerHTML=\"\"; \r\n" +
                        "     document.getElementById(\"divResultInfo\").innerHTML=\"???\"; \r\n" +
                        " } \r\n" +


                        " function JumPageQuestion(PageIndex) \r\n" +
                        " { \r\n" +
                        "     document.getElementById('txtPageIndex').value=PageIndex;\r\n"+
                        "     document.getElementById(\"divProcessing\").innerHTML=Portal.Exam.Render.Question.GetProcessingText().value; \r\n" +
                        "     setTimeout(\"RealJumpPageQuestion()\",10); \r\n" +
                        " } \r\n" +

                        " function RealJumpPageQuestion() \r\n" +
                        " { \r\n" +
                        "     PageIndex=document.getElementById(\"txtPageIndex\").value; \r\n" +
                        "     GroupQuestionId=document.getElementById(\"drpSelectGroupQuestion\").options[document.getElementById(\"drpSelectGroupQuestion\").selectedIndex].value; \r\n" +
                        "     MonthiId=document.getElementById(\"drpSelectMonthi\").options[document.getElementById(\"drpSelectMonthi\").selectedIndex].value; \r\n" +
                        "     Type=document.getElementById(\"drpSelectType\").options[document.getElementById(\"drpSelectType\").selectedIndex].value; \r\n" +
                        "     Keyword=document.getElementById(\"txtKeyword\").value; \r\n" +
                        "     SelectLevelIndex = document.getElementById(\"drpSelectLevelQuestion\").selectedIndex; \r\n" +
                        "     SelectLevel = document.getElementById(\"drpSelectLevelQuestion\").options[SelectLevelIndex].value; \r\n" +
                        "     SiteId='"+SiteId+"';\r\n"+
                        "     retValue=Portal.Exam.Render.Question.GetHtml(SiteId, GroupQuestionId,MonthiId,Type, Keyword,SelectLevel, PageIndex).value; \r\n" +
                        "     if(retValue.indexOf(\"ERROR\")!=-1) \r\n" +
                        "     { \r\n" +
                        "         alert(retValue); \r\n" +
                        "         return; \r\n" +
                        "     } \r\n" +
                        "     document.getElementById(\"divProcessing\").innerHTML=\"\"; \r\n" +
                        "     document.getElementById(\"divQuestionMain\").innerHTML=retValue; \r\n" +
                        " } \r\n" +

                        " function ClientMoveQuestion(QuestionId)\r\n" +
                        " {\r\n" +
                        "     SiteId='"+SiteId+"';\r\n"+
                        "     Url=Portal.Exam.Render.Question.GetMoveUrlForm(SiteId, QuestionId).value;\r\n" +
                        "     if(Url.indexOf(\"ERROR\")!=-1)\r\n" +
                        "     {\r\n" +
                        "         alert(Url);\r\n" +
                        "         return;\r\n" +
                        "     }\r\n" +
                        "     window.open(Url, '_self'); \r\n" +
                        " }\r\n" +

                        " function ShowClientHtmlEditorForm(QuestionId)\r\n" +
                        " {\r\n" +
                        "     SiteId='"+SiteId+"';\r\n"+
                        "     Url=Portal.Exam.Render.Question.GetUrlUpdateHtmlEditor(SiteId, QuestionId).value;\r\n" +
                        "     if(Url.indexOf(\"ERROR\")!=-1)\r\n" +
                        "     {\r\n" +
                        "         alert(Url);\r\n" +
                        "         return;\r\n" +
                        "     }\r\n" +
                        "     window.open(Url, '_self'); \r\n" +
                        " }\r\n" +

                        " function ResetSearch()\r\n" +
                        "  {\r\n" +
                        "     document.getElementById(\"divProcessing\").innerHTML=\"\";\r\n" +
                        "     document.getElementById(\"divResultContent\").innerHTML=\"\";\r\n" +
                        "     document.getElementById(\"divResultInfo\").innerHTML=\"???\";\r\n" +
                        " }\r\n" +


                        "</script>\r\n" +
                        " <div class=DatabaseFunction>\r\n" +
                        "        <ul>\r\n" +
                        "            <li onclick=\"javascript:ClientAddQuestion();\"><img class=image src=\""+IconRoot+"/Add.png\"><div>Thêm mới</div></li>\r\n" +
                        "            <li onclick=\"javascript:JumPageQuestion(0);\"><img class=image src=\"" + IconRoot + "/Refresh.png\"><div>Đọc lại</div></li>\r\n" +
                        "            <li onclick=\"javascript:window.open('../../folder.aspx?folder=exam','_self');\"><img class=image src=\"" + IconRoot + "/back.png\"><div>Quay lại</div></li>\r\n" +
                        "        </ul>\r\n" +
                        "  </div>\r\n" +
                        "<input id=txtPageIndex value=\"0\" type=hidden>\r\n"+
                        "<h3>Ngân hàng câu hỏi</h3>\r\n"+
                        "<div id=divQuestionMain class=cssDivQuestion>" + GetHtml(SiteId, GroupQuestionId, MonThiId, Type, "", "0", 0) + "</div>" +
                        "<script language=javascript>\r\n" +
                        "   JumPageQuestion(0);\r\n" +
                        "</script>\r\n";
                OAjaxOut.HtmlContent = RetHtml;
            }
            catch (Exception ex) 
            {
                OAjaxOut.Error = true;
                OAjaxOut.InfoMessage=ex.Message.ToString();
                OAjaxOut.HtmlContent = ex.Message.ToString();
            }
            return OAjaxOut;
        }

        [AjaxPro.AjaxMethod]
        public string GetAddQuestionUrl(string SiteId,string MonthiId,string Type)
        {
            try
            {
                WebSessionUtility.CheckSessionTimeOut(); 
                
                string Url = "";
                if (Type.ToLower().Equals("yesno".ToLower()))
                {
                    Url="AddYesNo.aspx?MonthiId="+MonthiId+"&type=AddYesNo";
                }
                if (Type.ToLower().Equals("bestanswer".ToLower()))
                {
                    Url = "AddBestAnswer.aspx?MonthiId="+MonthiId+"&type=AddBestAnswer";
                }

                //if (Type.ToLower().Equals("MultiChoice".ToLower()))
                //{
                //    Url = Screen.BuildUrl(
                //        SiteId,
                //        new ParamCls[]{
                //            new ParamCls("WebPartId",new AddMultiChoice().WebPartId),
                //            new ParamCls("MonthiId",MonthiId)
                //        });
                //}

                //if (Type.ToLower().Equals("FreeText".ToLower()))
                //{
                //    Url = Screen.BuildUrl(
                //        SiteId,
                //        new ParamCls[]{
                //            new ParamCls("WebPartId",new AddFreeText().WebPartId),
                //            new ParamCls("MonthiId",MonthiId),
                //            new ParamCls("Type",Type),
                //        });
                //}
                //if (Type.ToLower().Equals("LargeFreeText".ToLower()))
                //{
                //    Url = Screen.BuildUrl(
                //        SiteId,
                //        new ParamCls[]{
                //            new ParamCls("WebPartId",new AddFreeText().WebPartId),
                //            new ParamCls("MonthiId",MonthiId),
                //            new ParamCls("Type",Type),
                //        });
                //}
                if (Url.Trim().Length == 0)
                {
                    throw new Exception("Chưa xác định màn hình thêm mới cho loại: " + Type);
                }
                return Url;
            }
            catch (Exception ex)
            {
                return "ERROR: " + ex.Message.ToString();
            }
        }


        [AjaxPro.AjaxMethod]
        public string GetConfirmDeleteMsg(string SiteId)
        {
            return "Bạn đã chắc chắn xóa chưa?";
        }


        [AjaxPro.AjaxMethod]
        public string ServerSideCheckDeleteQuestion(string SiteId,string QuestionId)
        {
            try
            {
                WebSessionUtility.CheckSessionTimeOut(); 
                return "";
            }
            catch (Exception ex)
            {
                return "ERROR: " + ex.Message.ToString();
            }
        }

        [AjaxPro.AjaxMethod]
        public string ServerSideDeleteQuestion(string SiteId,string QuestionId)
        {
            try
            {
                WebSessionUtility.CheckSessionTimeOut(); 
                new QuestionBll().DeleteQuestion(null, SiteId, QuestionId);
                return "Xóa thành công";
            }
            catch (Exception ex)
            {
                return "ERROR: " + ex.Message.ToString();
            }
        }



        [AjaxPro.AjaxMethod]
        public string GetShowUpdateForm(string SiteId,string QuestionId)
        {
            try
            {
                WebSessionUtility.CheckSessionTimeOut(); 
                QuestionCls QuestionCls = new QuestionBll().CreateModel(SiteId, QuestionId);

                string UpdateUrl = "";
                if (QuestionCls.Type.ToLower().Equals("yesno"))
                {
                    UpdateUrl = "UpdateYesNo.aspx?QuestionId="+QuestionId;
                }
                if (QuestionCls.Type.ToLower().Equals("bestanswer"))
                {
                    UpdateUrl = "UpdateBestAnswer.aspx?QuestionId="+QuestionId;
                }
                //if (QuestionCls.Type.ToLower().Equals("MultiChoice".ToLower()))
                //{
                //    UpdateUrl = Screen.BuildUrl(
                //        SiteId,
                //        new ParamCls[]{
                //        new ParamCls("WebPartId",new UpdateMultiChoice().WebPartId),
                //        new ParamCls("QuestionId",QuestionId)
                //    });
                //}
                //if (QuestionCls.Type.ToLower().Equals("FreeText".ToLower()))
                //{
                //    UpdateUrl = Screen.BuildUrl(
                //        SiteId,
                //    new ParamCls[]{
                //        new ParamCls("WebPartId",new UpdateFreeText().WebPartId),
                //        new ParamCls("QuestionId",QuestionId)
                //    });
                //}

                //if (QuestionCls.Type.ToLower().Equals("LargeFreeText".ToLower()))
                //{
                //    UpdateUrl = Screen.BuildUrl(
                //        SiteId,
                //        new ParamCls[]{
                //        new ParamCls("WebPartId",new UpdateFreeText().WebPartId),
                //        new ParamCls("QuestionId",QuestionId)
                //    });
                //}
                if (UpdateUrl.Trim().Length == 0)
                {
                    throw new Exception("Không cung cấp tính năng sửa chữa cho loại: " + QuestionCls.Type);
                }
                return UpdateUrl;
            }
            catch (Exception ex)
            {
                return "ERROR: " + ex.Message.ToString();
            }
        }



        [AjaxPro.AjaxMethod]
        public string GetMoveUrlForm(string SiteId,string QuestionId)
        {
            try
            {
                WebSessionUtility.CheckSessionTimeOut(); 

                string MoveUrl =  "MoveQuestion.aspx?QuestionId="+QuestionId;
                return MoveUrl;
            }
            catch (Exception ex)
            {
                return "ERROR: " + ex.Message.ToString();
            }
        }

        [AjaxPro.AjaxMethod]
        public string GetProcessingText(string SiteId)
        {
            
            return "Đang đọc dữ liệu từ máy chủ";
        }


        [AjaxPro.AjaxMethod]
        public string GetUrlUpdateHtmlEditor(string SiteId,string QuestionId)
        {
            try
            {
                WebSessionUtility.CheckSessionTimeOut();
                return "HtmlEditor.aspx?QuestionId=" + QuestionId;
            }
            catch (Exception ex)
            {
                return "ERROR: " + ex.Message.ToString();
            }
        }
    }
}
